package cn.kiliter.web.servlet.demo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@WebServlet("/cesuo")
public class cesuoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<String> list1=new ArrayList<>();
        List<String> list2=new ArrayList<>();
        List<String> list3=new ArrayList<>();
        List<String> list4=new ArrayList<>();
        List<String> flag=new ArrayList<>();
        String[] array={
                "张家林","许璞","郭立清","童优",
                "张家林","许璞","郭立清","童优",
                "张家林","许璞","郭立清","童优",
                "张家林","许璞","郭立清","童优",
                "张家林","许璞","郭立清","童优",
                "张家林","许璞","郭立清","童优",
                "张家林","许璞","郭立清","童优"};

        for (int i=0;i<array.length;i++){
            flag.add(array[i]);
        }
        Collections.shuffle(flag);
        for (int i = 0; i < flag.size(); i++) {
            if(i%4==0){
                list1.add(flag.get(i));
            }
            if(i%4==1){
                list2.add(flag.get(i));
            }
            if(i%4==2){
                list3.add(flag.get(i));
            }
            if(i%4==3){
                list4.add(flag.get(i));
            }
        }
        request.setAttribute("list1",list1);
        request.setAttribute("list2",list2);
        request.setAttribute("list3",list3);
        request.setAttribute("list4",list4);
        request.getRequestDispatcher(request.getContextPath()+"/demoooooo.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
